using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DTLAutomateGUI.Data;

namespace DTLAutomateGUI.Controls.LayoutControls
{
	public partial class DumbBorderControl : DTLAutomateGUI.Controls.LayoutControls.LayoutItemControl
	{
		public DumbBorderControl(DataSetLayout.BorderRow row)
		{
			InitializeComponent();
			this.dataRow = row;
			this.dataRow.Table.RowChanged += new DataRowChangeEventHandler(Table_RowChanged);
			//this.nameLabel.Text = row.name;
			this.Location = new Point(row.locationX, row.locationY);
		}

		void Table_RowChanged(object sender, DataRowChangeEventArgs e)
		{
			if (e.Row == this.dataRow)
			{
				if ((!this.moving) && (this.Location != new Point(this.dataRow.locationX, this.dataRow.locationY)))
				{
					this.Location = new Point(this.dataRow.locationX, this.dataRow.locationY);
				}
				this.nameLabel.Text = this.dataRow.name;
			}
		}

		#region properties

		private DataSetLayout.BorderRow dataRow;
		public DataSetLayout.BorderRow DataRow
		{
			get { return dataRow; }
		}


		#endregion

		private void DumbBorderControl_LocationChanged(object sender, EventArgs e)
		{
			if (this.moving)
			{
				this.dataRow.locationX = this.Location.X;
				this.dataRow.locationY = this.Location.Y;
			}
		}
	}
}

